<?php

use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
use Dcat\Admin\Admin;

Admin::routes();

Route::group([
    'prefix'        => config('admin.route.prefix'),
    'namespace'     => config('admin.route.namespace'),
    'middleware'    => config('admin.route.middleware'),
], function (Router $router) {
    $router->get('/', 'HomeController@index');
    // 按照楼栋数据统计
    $router->get('index2', 'HomeController@index2');
    // 按照月份进行数据统计
    $router->get('index3', 'HomeController@index3');

    // 房产模型
    $router->name('admin')->resource('/house', 'HouseController');
    // 楼栋搜索
    $router->get('api/building', 'BuildingController@buildingApi');
    // 根据house_id获取builidng列表
    $router->get('/building/{houseId}/house', 'BuildingController@getByHouseId');
    // 房间配置
    $router->name('admin')->resource('room-config', 'RoomConfigController');
    // 管理员电话表
    $router->name('admin')->resource('admin-mobile', 'AdminMobileController');
    // 公共收费项
    $router->name('admin')->resource('house-fee-config', 'HouseFeeConfigController');

    // 房间模型
    $router->get('room/create', 'RoomController@create')->name('admin.room.create');
    $router->post('room', 'RoomController@store')->name('admin.room.store');
    $router->get('room/{id}/edit', 'RoomController@edit')->name('admin.room.edit');
    $router->post('room/{id}', 'RoomController@update')->name('admin.room.update');
    $router->get('room', 'RoomController@index')->name('admin.room.index');
    $router->get('api/room', 'RoomController@roomApi');

    // 用户模型
    $router->name('admin')->resource('user', 'UserController');
    // 租客模型
    $router->get('owner/test', 'OwnerController@test');
    // 合同列表
    $router->name('admin')->resource('owner', 'OwnerController');
    // 未收账单 (即将废弃)
    $router->name('admin')->resource('pending-bill', 'OwnerItem\PendingBillController');
    // 未收账单 (新)
    $router->get('running-water', 'OwnerItem\RunningWaterController@index')->name('admin.running-water.index');
    // 确认收租
    $router->post('running-water/{bill}/pay', 'OwnerItem\RunningWaterController@pay')->name('admin.running-water.pay');
    // 历史流水
    $router->get('running-water/{owner}/history-bill', 'OwnerItem\RunningWaterController@showHistoryBill')->name('admin.running-water.history-bill');
    // 更新杂费
    $router->post('running-water/{bill}/other-amount', 'OwnerItem\RunningWaterController@updateOtherAmount')->name('admin.running-water.update-other-amount');
    // 更新抄表
    $router->post('running-water/{bill}/update-meter', 'OwnerItem\RunningWaterController@updateMeter')->name('admin.running-water.update-meter');
    // 一次性收费
    $router->post('running-water/{bill}/update-once', 'OwnerItem\RunningWaterController@updateOnce')->name("admin.running-water.update-once");
    // 续约合同逻辑
    $router->put('renew/{owner}', 'OwnerItem\RunningWaterController@renew')->name('admin.renew.update');
    // 续约合同界面
    $router->get('renew/{owner}/edit', 'OwnerItem\RunningWaterController@editRenew')->name('admin.renew.edit');
    // 结束合同界面
    $router->get('finish/{owner}/edit', 'OwnerItem\RunningWaterController@editFinish')->name('admin.finish.edit');
    // 结束合同逻辑
    $router->put('finish/{owner}', 'OwnerItem\RunningWaterController@updateFinish')->name('admin.finish.update');
    // 显示单据
    $router->get('pending-bill/{bill}/document', 'OwnerItem\PendingBillController@document')->name('admin.pending-bill.document');
    $router->get('pending-bill/{bill}/pdf', 'OwnerItem\PendingBillController@documentPdf')->name('admin.pending-bill.pdf');
    // 待租客支付账单， 更新抄表数据
    $router->post('pending-bill/{bill}/other-amount', 'OwnerItem\PendingBillController@updateOtherAmount')->name('admin.pending-bill.update-other-amount');
    // 账单列表
    $router->name('admin')->resource('bill', 'OwnerItem\BillController');
    // 待抄表账单
    $router->name('admin')->resource('meter-reading', 'OwnerItem\MeterReadingController');
    // 待抄表列表中， 更新抄表数据
    $router->post('meter-reading/{bill}/other-amount', 'OwnerItem\MeterReadingController@updateOtherAmount')->name('admin.meter-reading.update-other-amount');
    // 已支付账单
    $router->name('admin')->resource('pay-bill', 'OwnerItem\PayBillController');
    // 收入历史
    $router->name('admin')->resource('bill', 'OwnerItem\BillController');
    // 租约即将到期，默认10天
    $router->name('admin')->resource('lease-expires', 'Owner\LeaseExpiresController');
    // 合同过期
    $router->name('admin')->resource('contract-expired', 'Owner\ContractExpiredController');
    // 租借房间历史
    $router->name('admin')->resource('history-rent', 'HistoryRentController');
    // 消息列表
    $router->name('admin')->resource('send', 'SendController');
    // 短信推送中心
    $router->get('sms-operation', "SmsOperationController@index")->name("admin.sms.operation");
    // 短信推送给某个人
    $router->get('sms-person/create', "SmsOperationController@sendPersonCreate")->name("admin.sms.person.create");
    $router->post('sms-person', "SmsOperationController@sendPersonStore")->name("admin.sms.person.store");
    // 群发短信给租客们
    $router->post('send-sms/{templateId}/to-owners', "SmsOperationController@sendOwnersByTemplate")->name("admin.sms.send-owners");
    // 群发短信发送给管理员们
    $router->post('send-sms/{templateId}/to-admins', "SmsOperationController@sendAdminsByTemplate")->name("admin.sms.send-admins");
    // 智能电表
    $router->name('admin')->resource('electric-meter', 'Equipment\ElectricMeterController');
    // 智能水表
    $router->name('admin')->resource('water-meter', 'Equipment\WaterMeterController');
    // 记账类型
    $router->name('admin')->resource('fund', 'FundController');
    // 开发者测试
    $router->name("admin")->get("admin-test", "AdminTestController@index");
    $router->name("admin")->post("admin-test/delete-all", "AdminTestController@deleteAll");
    $router->name("admin")->post("admin-test/{id}/store-data", "AdminTestController@storeData");
    $router->name("admin")->get("admin-test/close-owner", "AdminTestController@closeOwnerByWillClose");
    $router->name("admin")->post("admin-test/expires", "AdminTestController@expires");

    // 收款表头
    $router->name('admin')->resource('receive-payment/header', 'ReceivePaymentHeaderController');
    // 收款表体
    $router->name('admin')->resource('receive-payment/body', 'ReceivePaymentBodyController');
    // 收款表
    $router->name('admin')->resource('receive-payment', 'ReceivePaymentController');
    $router->name('admin')->resource('wt-request', 'WtRequestController');

});
